-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to the protoc code generator to avoid generating deprecated code #3089
base: main
Are you sure you want to change the base?
Add option to the protoc code generator to avoid generating deprecated code #3089
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Token approval: this looks fine to me but please wait for a more experienced reviewer before merging.
How was it tested? I presume manually, but it would be good to document it in the PR description.
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Main.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
…ing-deprecated-calls
…est full scope of generation
New diff from test_service.proto: https://gist.github.com/mgodave/5772193156ca740ea90ca11bafb3da56 |
…oc/Main.java Co-authored-by: Idel Pivnitskiy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good progress! New generated code looks much better than without skipDeprecated
option.
Just a few adjustments for the final findings and we are ready to ship:
|
||
package grpc.netty; | ||
|
||
service Tester { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was handy to use this file for validation of all API variants, but we should not add it to this example if we don't use it. Let's remove for now and we can reconsider the approach for the future similar to what you discussed with Bryce on how to observe the differences in generated code as part of PR review (follow-up).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it was handy for testing I feel like we should leave it or add another project just for this. I'm happy to add a usage here but it seems kind of counterproductive to have to copy/paste something in here every time we want to generate a comprehensive example for testing/comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove it at the end before merging PR. It just doesn't fit into this example. And creating another module is a bit out of scope of this PR, we will plan that for the follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcRoutes.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcRoutes.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
The generated code with skipDeprecated=true
looks good. I also checked diff for default behavior. Many things changed their order, which is ok. Couldn't spot anything suspicious, but would be great if someone can have another look at the diff @bryce-anderson. We need to make sure current users won't be affected.
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
…oc/Generator.java
Motivation
The generated ServiceTalk gRPC stubs make use of deprecated calls. This causes a problem when
-Werror
is used to build the code since it will automatically fail the build. We should allow users who have already migrated their code to prevent the protoc compiler from generating and using deprecated references.Modifications
Add an option,
skipDeprecated
, as part of the protoc compiler configuration, to tell the generator to leave out deprecated references.Result
Example: Tester.java before/after https://gist.github.com/mgodave/5772193156ca740ea90ca11bafb3da56
Remove
Testing
Manually tested: